package com.haofengsoft.scce.ui.mine;

import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.ImageView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.haofengsoft.scce.R;
import com.haofengsoft.scce.common.client.VolleyBean;
import com.haofengsoft.scce.common.client.VolleyInterface;
import com.haofengsoft.scce.common.client.VolleyManage;
import com.haofengsoft.scce.common.config.ConstantConfig;
import com.haofengsoft.scce.common.security.Base64Helper;

public class AboutUsActivity extends Activity {

    private WebView contentWv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.aboutus);
        ImageView backIv = (ImageView) findViewById(R.id.aboutus_title_back_iv);
        backIv.setOnClickListener(new BackClickListener());

        contentWv = (WebView) findViewById(R.id.aboutus_wbv);
        contentWv.getSettings().setDefaultTextEncodingName("UTF-8");
        initData();
    }

    private void initData() {
        Map<String, Object> mapParam = new HashMap<String, Object>();
        mapParam.put("nodata", "");
        VolleyManage.getInstance().methodPost(AboutUsActivity.this, null, ConstantConfig.ABOUT_US_URL, mapParam, new AboutUsReal());
    }

    class AboutUsReal implements VolleyInterface {

        @Override
        public void gainData(VolleyBean bean) {
            if (bean.isSuccess()) {
                JSONObject parObj = JSON.parseObject(bean.getContent());
                byte[] contentByte = Base64Helper.decode(parObj.getString("Contents"));
//                contentWv.loadData(new String(contentByte), "text/html", "UTF-8");
                contentWv.loadDataWithBaseURL(null, new String(contentByte), "text/html", "UTF-8", null);
            }
        }
    }


    class BackClickListener implements OnClickListener {

        @Override
        public void onClick(View view) {
            finish();
        }
    }

    ;

}
